package com.gdust.lease.common.mybatisplus;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: MybatisPlusConfiguration
 * Package: com.gdust.lease.common.mybatisplus
 * Description:MyBatis Plus配置类
 * 用于MyBatis Plus相关的配置
 * 通过@MapperScan注解，Spring会扫描指定包路径下的所有Mapper接口并将其注册到Spring容器中
 * MyBatis Plus会根据这些接口生成相应的Mapper实现类
 * @Author syun
 * @Create 2025/1/1 14:13
 * @Version 1.0
 */
@Configuration//声明这是一个配置类，Spring框架会根据此注解将其识别为配置类
@MapperScan("com.gdust.lease.web.*.mapper")// 配置MyBatis的Mapper接口扫描包路径，自动将指定包路径下的接口注册为MyBatis的Mapper接口
public class MybatisPlusConfiguration {

    /**
     *  //配置Mybatis-Plus分页插件
     * @return 分页对象
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

}
